package com.lagou.consumer;

import com.lagou.api.HelloService;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import redis.clients.jedis.JedisPool;

import java.io.IOException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @Authther: mrwu
 * @date:2021/4/11-04
 * @Description:com.lagou.consumer
 */
public class ConsumerMain {
    public static void main(String[] args) throws IOException, InterruptedException {
        ClassPathXmlApplicationContext context =
                new ClassPathXmlApplicationContext("classpath:dubbo-consumer.xml");
        context.start();
        HelloService helloService = (HelloService) context.getBean(HelloService.class);
        ExecutorService executorService = Executors.newFixedThreadPool(200);

        while (true){
            Thread.sleep(10);
            executorService.execute(new Runnable() {
                @Override
                public void run() {//每10毫秒调用6次则每秒调用600次
                    for (int i = 0; i < 2; i++) {
                        helloService.hello();
                        helloService.call();
                        helloService.say();
                    }
                }
            });
        }

    }
}
